package com.fy.oa.zc.service;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.seeyon.apps.collaboration.event.AbstractCollaborationEvent;
import com.seeyon.v3x.services.V3XLocator;

/**
 * OA事件分发
 * 
 * @author 郑志诚
 */
public class FyOAFormEventDistribution implements Runnable {
	private static final Log logger = LogFactory.getLog(FyOAFormEventDistribution.class);

	private int count = 0;

	private AbstractCollaborationEvent event;

	/**
	 * 设置本次触发事件
	 * 
	 * @param event
	 */
	public void setEvent(AbstractCollaborationEvent event) {
		this.event = event;
	}

	@Override
	public void run() {
		// 判断触发事件，进行处理
		try {
			FyOAFormEventDeal fyOAFormEventDeal = V3XLocator.getInstance().lookup(FyOAFormEventDeal.class);
			fyOAFormEventDeal.deal(event);
		} catch (Exception e) {
			pringLog("监听事件发生异常");
		}
	}

	private void pringLog(String msg) {
		logger.error(msg);
		System.out.println(msg);
	}

	@Override
	public String toString() {
		return "FyOAFormEventDistribution [count=" + count++ + "]";
	}
}
